package com.informationsystem.webapp.action;

import java.util.List;

import com.informationsystem.dao.SearchException;
import com.informationsystem.model.Downloads;
import com.informationsystem.model.News;
import com.informationsystem.service.NewsManager;

public class InfoCenter_News_Action extends BaseAction {
	private NewsManager newsManager;
	private List newsList;
	private News news;
	private Long id;
	public NewsManager getNewsManager() {
		return newsManager;
	}

	public void setNewsManager(NewsManager newsManager) {
		this.newsManager = newsManager;
	} 
	
    public String list() {
    	setNewsList(newsManager.getNewsList());
        return SUCCESS;
    }
    
    public String view(){
	   if (getId() != null) {
           setNews(newsManager.get(getId()));
           news.setViewTimes(news.getViewTimes()+1);
           newsManager.save(news);
       } else {
           setNews(new News());
       }

       return SUCCESS;
    }

	public List getNewsList() {
		return newsList;
	}

	public void setNewsList(List newsList) {
		this.newsList = newsList;
	}

	public News getNews() {
		return news;
	}

	public void setNews(News news) {
		this.news = news;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
}
